<?php
error_reporting ( E_ALL );

// Con | añado errores
// Con ^ quito errores, para no ver los STRICT, e_all ^ e_strict
// E_ERROR indica que se ha producido un error fatal que impide la ejecución del script.
// E_WARNING indica una advertencia, la ejecucion del script continua.
// E_NOTICE indica anotaciones sobre posibles errores, por ejemplo, variables no inicializadas, equivocaciones en los nombres de dichas variables, etc.

// Funcion standard AUTOLOAD
function __autoload($name) {
	throw new Exception ( $name );
}

// Nombre de la aplicación 
define ( "APPLICATION_NAME", "imarkket" );
define ( "APPLICATION_WEB_DOMAIN", "www.imarkket.org" );
define ( "APPLICATION_PAID_DOMAIN", "http://interactua.dnsapi.info" );
// Activar esto solo cuando page por el dominio
define ( "USE_APPLICATION_PAID_DOMAIN", FALSE );

// Definición de las variables de la application
define ( "VERSION_HIGH",        0 );
define ( "VERSION_LOW",         1 );
define ( "VERSION_COMPILATION", 3 );

// Fecha 10/08/2013. Fecha de referencia para comparar con los campos de la tabla y si un campo es > que este y no da error
// se puede convertir en fecha
define ( "FECHA_ACTIVACION",    1376059684 );    

// binary values
// diferentes tipos de auditoria en la web

// Prioridades en la auditoría
define ( "AUDIT_NONE",            0 ); // 0000000
define ( "AUDIT_ERROR",           1 ); // 0000001
define ( "AUDIT_DB",              2 ); // 0000010
define ( "AUDIT_DB_SQL",          4 ); // 0000100
define ( "AUDIT_DB_SQL_FETCH",    8 ); // 0010000
define ( "AUDIT_APP",            16 ); // 0001000
define ( "AUDIT_EXTEND",         32 ); // 0100000
define ( "AUDIT_SESSION",        64 ); // 0100000                                                  
                                                   
// 00001
define ( "AUDIT_ALL",            63 ); // all possible options, NO VEO LAS SESSIONES, es un coñazo
                                       // 0111111

define ( "AUDIT_LEVEL",          AUDIT_ALL ); // Choose the audit level to user
define ( "AUDITAR_DB_SQL_FETCH", TRUE );  
define ( "AUDIT_SHOW_EXPAND_LOG",FALSE );
define ( "AUDIT_SHOW_LOG_DATE",  FALSE );

// En el fichero c_krn_exception.php se detallarán más las excepciones y errores
define ( "DUMP_ERROR", FALSE );
define ( "DUMP_EXCEPTION", FALSE );
define ( "DUMP_FATAL", FALSE );

// El fichero de log de errores se complementará¡ con la fecha del día del error LOG_ERROR_[Base de Datos]_[Día de hoy].log
define ( "LOG_NAME", APPLICATION_NAME . "-alert.log" );
define ( "RESET_LOG" , TRUE );
// "alert_".date("Ymd.H").".log";

// AUTO GEN PASSWORD http://www.thebitmill.com/tools/password.html
define ( "IV",          "fB&YR),lNZ2fmTX3" );
define ( "SEMILLA",     "o:~{m,pmFKeAg+o[r3b-9k2ue" );
define ( "SEMILLA_JAVA","o{mpmFKAg+o[r3b-" );

// mysql online or offline
define ( "BD_MOTOR",     "MySQL" );
define ( "APP_DIR",      "/www/app-imarkket/" );
define ( "APP_DIR_WEB",  APP_DIR . APPLICATION_NAME . "-web" . '/' );
define ( "APPLICATION_DIR",     $_SERVER ['DOCUMENT_ROOT'] . APP_DIR_WEB );
//define ( "APPLICATION_DIR",     $_SERVER ['DOCUMENT_ROOT'] );
define ( "APPLICATION_DIR_LOG", $_SERVER ['DOCUMENT_ROOT'] . APP_DIR . "log" . '/' );
//define ( "APPLICATION_DIR_LOG", $_SERVER ['DOCUMENT_ROOT'] . "../" . "log" . '/' );

// Para saber que clave de BD cargar
//echo APPLICATION_DIR."<br />";
//echo $_SERVER ['DOCUMENT_ROOT']."<br />";
//echo APP_DIR_WEB."<br />"; 

if (file_exists( APPLICATION_DIR . 'PRO.enviroment')) {
  // raspi
} else if (file_exists( APPLICATION_DIR . 'PRE.enviroment')) {
  // pc GC
	define ( "BD_SERVIDOR",  "10.52.128.163:3306" );
	define ( "BD_USUARIO",   APPLICATION_NAME );
	define ( "BD_PASSWORD",  APPLICATION_NAME );
	define ( "BD_NOMBRE",    APPLICATION_NAME );  
} else if (file_exists( APPLICATION_DIR . 'DES.enviroment')) {
  // pc portatil
	//define ( "BD_SERVIDOR",  "192.168.1.36:3306" ); // ip en casa
	//define ( "BD_SERVIDOR",  "192.168.0.198:3306" );  // ip en casa foz
	//define ( "BD_SERVIDOR",  "127.0.0.1:3306" );  // ip en casa foz
	define ( "BD_SERVIDOR",  "192.168.1.5:3306" );  // ip en casa foz
	define ( "BD_USUARIO",   APPLICATION_NAME );
	define ( "BD_PASSWORD",  APPLICATION_NAME );
	define ( "BD_NOMBRE",    APPLICATION_NAME );
} else {
  // desconocido
  echo "NO SE ENCUENTRA FICHERO enviroment ";
  define ( "APPLICATION_DIR", "APPLICATION_DIR_UNKNOWN" );
}

/*
if (MYSQL_ONLINE == 0) {
	define ( "BD_SERVIDOR", "mysql3.000webhost.com" );
	define ( "BD_NOMBRE", "a9904387_mysql" );
	define ( "BD_USUARIO", "a9904387_mysql" );
	define ( "BD_PASSWORD", "clave_a9904387_mysql" );
	define ( "APPLICATION_DIR", "/home/a9904387/public_html/web" );
	// host
	// - username: haelsite@hotmail.com
	// - password: ... + numero
	// Account hosting
	// - Dominio: imarkket.site40.net
	// - Username: a9904387
	// - password: asdfasdf1234
	// Account db
	// - Server: mysql3.000webhost.com
	// - Nombre: a9904387_mysql
	// - usuario: a9904387_mysql
	// - Password: clave_a9904387_mysq
	// phpmyadmin
	// - database: a9904387_mysql
	// - username: a9904387_phpMyAdmin
	// - password: a9904387_phpMyAdmin
	// ftp (conexion rápida con el ftp y funciona)
	// - servidor: imarkket.site40.net
	// - username: a9904387
	// - password: a9904387
} else if (MYSQL_ONLINE == 1) {
	define ( "BD_SERVIDOR", "hosting.zymic.com" );
	define ( "BD_NOMBRE", "jneivil_99k_imarkket" );
	define ( "BD_USUARIO", "765742_imarkket" );
	define ( "BD_PASSWORD", "765742_imarkket" );
	// host
	// - username: jneivil@gmail.com
	// - password: ...
	// Account hosting
	// - Dominio: jneivil.99k.org
	// - Username: -----
	// - password: la de siempre
	// Account db
	// - Server:
	// - Nombre:
	// - usuario:
	// - Password:
	// phpmyadmin
	// - database:
	// - username:
	// - password:
	// ftp (conexion rápida con el ftp y funciona)
	// - servidor:
	// - username:
	// - password:
} else if (MYSQL_ONLINE == 2) {
	//ip pc gc
	//define ( "BD_SERVIDOR",  "10.52.128.163:3306" );
	//ip portatil
	define ( "BD_SERVIDOR",  "192.168.1.36:3306" );
	define ( "BD_USUARIO",   APPLICATION_NAME );
	define ( "BD_PASSWORD",  APPLICATION_NAME );
	define ( "BD_NOMBRE",    APPLICATION_NAME );
	define ( "APPLICATION_DIR", $_SERVER ['DOCUMENT_ROOT'] . "/www/" . APPLICATION_NAME . "-web" );
}
*/

define ( "COUNTER_COOKIE", "cookier_counter" );
define ( "GRAFICAL_COUNTER", 1 );
define ( "NON_GRAFICAL_COUNTER", 0 );

// Definimos los diferentes tipos de conexiones
define ( "CONNECT_WEB", "APP_WEB" );
define ( "CONNECT_MOVIL", "APP_MOVIL" );
define ( "CONNECT_TABLET", "APP_TABLET" );
define ( "CONNECT_NULL", "APP_UNKNOWN" );

define ( "FORM_OPERATION_NULL", "CONNECT_NULL" );

define ( "TABLA_USUARIOS", "t_usuarios" );
define ( "TABLA_INVITADOS", "t_invitados" );
define ( "TABLA_OPERACIONES", "t_operaciones" );
define ( "TABLA_ADMIN", "t_admin_tablas" );
define ( "TABLA_CONEXION", "t_conexion" );
define ( "TABLA_LISTA_USUARIO", "t_lista_usuario" );
define ( "TABLA_LISTA_COMPRA", "t_lista_compra" );
define ( "TABLA_APLICACIONES", "t_aplicaciones" );
define ( "TABLA_MODOS_APP", "t_modos_aplicacion" );
define ( "TABLA_USUARIO_APP", "t_usuario_aplicacion" );
define ( "TABLA_LC_ELEMENTOS", "t_lista_compra_elementos" );
define ( "TABLA_ELEMENTOS_USUARIO", "t_elementos_usuario" );

define ( "NOMBRE_INVITADO", "INVITADO" );
define ( "EMAIL_ADMIN", "haelsite@hotmail.com" );

define ( "TIME_USUARIO", 10 ); // 600 segundos
define ( "TIME_INVITADO", 5 ); // 300 segundos
define ( "TIME_PENDING_ACTIVATE", 60 * 60 * 2 ); // 2 horas

define ( "LOGIN_MAX_INTENTOS",      3 ); // Maximo intentos fallidos hasta bloqueo cuenta
define ( "LOGIN_MAX_INTENTOS_TIME", 86400 ); // Limite de tiempo en los intentos en 24h

// Motivos de bloqueo de usuario                  

define ( "LOGIN_STATUS",          serialize (array ("ACTIVE", 
                                                    "INACTIVE", 
                                                    "BLOCKED",
                                                    "PENDING_ACTIVATE")));

// Configuración MAIL phpMailer versión 5.2.4
define ( "MAILSMTPAuth", true ); // enable SMTP authentication
define ( "MAILSMTPSecure", "ssl" ); // sets the prefix to the servier
define ( "MAILHost", "smtp.gmail.com" ); // sets GMAIL as the SMTP server
define ( "MAILPort", 465 ); // set the SMTP port
define ( "MAILUsername", "interactua.dev@gmail.com" ); // GMAIL username
define ( "MAILPassword", "passportinteractua" ); // GMAIL password
define ( "MAILFrom",     MAILUsername ); 
define ( "MAILFromName", APPLICATION_NAME );
define ( "MAILSubject",  APPLICATION_NAME. ": Application Activated Required" );
define ( "MAILAltBody",  APPLICATION_NAME. ": Application Activated Required" ); //Text Body
define ( "MAILWordWrap", 50 ); // set word wrap
define ( "MAILAddReplyToEmail", MAILUsername );
define ( "MAILAddReplyToName", "Administrador" );
define ( "MAILisHTML", true ); // send as HTML
define ( "MAILSMTPDebug", 1 );

// Tipos de Idioma
define ( "ES", 0 ); // es
define ( "EN", 1 ); // en
                                                    
// Definimos el idioma
$IDIOMA = ES;

// Constantes de texto
$language [0] [0] = "es";
$language [0] [1] = "Este error no está incluido en ERROR_REPORTING";
$language [0] [2] = "Error cargando clase: ";
$language [0] [3] = "Iniciando aplicación...";
$language [0] [4] = "Conectando... ";
$language [0] [5] = "Conexión: ok ";
$language [0] [6] = "Autorización no válida, acceso denegado.";
$language [0] [7] = "Lista de la Compra";
$language [0] [8] = "No se encuentra: ";
$language [0] [9] = "Iniciando sesión...";
$language [0] [10] = "EXPIRE SESSION: ";
$language [0] [11] = "Comprobando login";
$language [0] [12] = "LOAD   SESSION: ";
$language [0] [13] = "Presente en BD: ";
$language [0] [14] = "Logueado: ";
$language [0] [15] = "NEW    SESSION: ";
$language [0] [16] = "USER   SESSION: ";
$language [0] [17] = "Error al conectar a la BD.";
$language [0] [18] = "El usuario introducido no existe.";
$language [0] [19] = "El identificador de usuario es erróneo.";
$language [0] [20] = "Email no introducido.";
$language [0] [21] = "Email con formato incorrecto.";
$language [0] [22] = "Password incorrecto.";
$language [0] [23] = "No existen datos del usuario o password incorrecto.";
$language [0] [24] = "Desconexion por caducidad de sesion: ";
$language [0] [25] = "Cargando página principal...";
$language [0] [26] = APPLICATION_NAME . " :: ";
$language [0] [27] = "http://creativecommons.org/licenses/by-nc-nd/3.0/deed.es_CO";
$language [0] [28] = "Login";
$language [0] [29] = "Email";
$language [0] [30] = "Contraseña";
$language [0] [31] = "Acceder";
$language [0] [32] = "Recordar clave";
$language [0] [33] = "¿Recuperar clave?";
$language [0] [34] = "CONNECT_MODE: ";
$language [0] [35] = "AUTO_LOAD_HTML: ";
$language [0] [36] = "Donativo";
$language [0] [37] = "Condiciones y Privacidad";
$language [0] [38] = "Registrarme";
$language [0] [39] = "Usted ya está logeado en el sistema.";
$language [0] [40] = "Error cargando el conjunto de caracteres UTF-8:";
$language [0] [41] = "Conjunto de caracteres actual: ";
$language [0] [42] = "Empezar";
$language [0] [43] = "Usuarios activos";
$language [0] [44] = "FORM OPERATION: ";
$language [0] [45] = "SESSION_ID=null";
$language [0] [46] = "Login   OK: ";
$language [0] [47] = "Login FAIL: ";
$language [0] [48] = " intentos de acceso fallidos en menos de ".round(LOGIN_MAX_INTENTOS_TIME / 60 / 60)." horas. Bloqueando usuario.";
$language [0] [49] = " intentos de acceso fallidos.";
$language [0] [50] = "No existe usuario";
$language [0] [51] = "LOGIN: ";
$language [0] [52] = "ADMIN LOGIN: ";
$language [0] [53] = "URL: ";
$language [0] [54] = "LOGOUT: ";
$language [0] [55] = "Exit";
$language [0] [56] = "Time: ";
$language [0] [57] = "Error confirmando identidad del usuario: ";
$language [0] [58] = "Foro";
$language [0] [59] = " ** Error clase ** ";
$language [0] [60] = "Cerrar sesión";
$language [0] [61] = "Usted NO está logueado en el sistema, o es una APP_MOVIL";
$language [0] [62] = "PARAM: ";
$language [0] [63] = "URL: ";
$language [0] [64] = "ERROR: tabla t_aplicacion.ncod_counter";
$language [0] [65] = "Visitas: ";
$language [0] [66] = "Esta herramienta está desarrollada para al gestión de las compras domésticas y obtener el mayor beneficio de los productos aquiridos´al menor coste posible para usuario.";
$language [0] [67] = "Generando HTML...";
$language [0] [68] = "Conectando usuario...";
$language [0] [69] = "Desconectando usuario...";
$language [0] [70] = "JSON: no error";
$language [0] [71] = "JSON: stack excedida";
$language [0] [72] = "JSON: cadena mal construida";
$language [0] [73] = "JSON: error en el control de caracteres, posiblemente mal codificado";
$language [0] [74] = "JSON: error de sintaxis";
$language [0] [75] = "JSON: UTF-8 mal construido, posiblemente codificación incorrecta";
$language [0] [76] = "Licencia Creative Commons";
$language [0] [77] = "ERROR_CASE_CLASS_PROC_UNKNOWN: ";
$language [0] [78] = "Administrar";
$language [0] [79] = "ERROR_CASE_CLASS_WEB: ";
$language [0] [80] = "ERROR_CASE_CLASS_WEB_getHTML_web: ";
$language [0] [81] = "Licencia";
$language [0] [82] = "About";
$language [0] [83] = "Captcha CHECKING: ";
$language [0] [84] = "<strong>Longitud: 8<br />Minúsculas, <br />Mayúsculas, <br />Números, <br />Caracteres especiales</strong>";
$language [0] [85] = "Nuevo Usuario";
$language [0] [86] = "PANIC: *** Error en la carga de la sesión ***";
$language [0] [87] = "Invitado YA CONECTADO, recuperando variables de Sesión: ";
$language [0] [88] = "No se han establecido las variables de entorno";
$language [0] [89] = "JSON: ";
$language [0] [90] = "Acceso a " . $language [0] [26];
$language [0] [91] = "Introduzca los datos para crear un nuevo usuario en la herramienta. Debe introducir un email válido y rellenar correctamente el captcha para poder validar la operación.";
$language [0] [92] = "Conexión: ";
$language [0] [93] = "** ERROR ** ";
$language [0] [94] = "setSession: ";
$language [0] [95] = "getSession: ";
$language [0] [96] = "Listas de la Compra: ";
$language [0] [97] = "Re-conectando usuario: ";
$language [0] [98] = "Elementos: ";
$language [0] [99] = "Registrando usuario: ";
$language [0] [100] = "España";
$language [0] [101] = "Nueva Lista";
$language [0] [102] = "Pendientes";
$language [0] [103] = "Finding user: ";
$language [0] [104] = "Inserting user: ";
$language [0] [105] = "Sending eMAIL: ";
$language [0] [106] = "Activated user: ";
$language [0] [107] = "ENCRYPT - json";
$language [0] [108] = "DECRYPT - json";
$language [0] [109] = "Shopping List exist... abort: ";
$language [0] [110] = "Shopping List not exist... creating: ";
$language [0] [111] = "Modo acceso aplicación erróneo";
$language [0] [112] = "Acceso Autorizado.";
$language [0] [113] = "Acceso NO Autorizado.";

$language [1] [0] = "en";
$language [1] [1] = "This error isn't included in ERROR_REPORTING";
$language [1] [2] = "Loading class error: ";
$language [1] [3] = "Starting application...";
$language [1] [4] = "Connecting... ";
$language [1] [5] = "Connect: ok ";

$language [1] [7] = "Error Type: ";

/*		  
		  $file = LOG_NAME;
			$path = APPLICATION_DIR_LOG;
			
      $path = $path . '/' . $file;

  	  // Resetear el log si lo hemos definido en la configuración
		  IF ( RESET_LOG ) {
        $ourFileHandle = fopen($path, 'w') or die("can't open file");
        fclose($ourFileHandle);
		  }
 */


?>
